//
//  SettlementViewModel.m
//  HarmonizePub
//
//  Created by rzhy on 2017/6/14.
//  Copyright © 2017年 rzhy. All rights reserved.
//

#import "SettlementViewModel.h"
#import "Config.h"
#import "Settlement.h"

@interface SettlementViewModel ()

@property (nonatomic, strong) NSArray *array;

@end

@implementation SettlementViewModel

- (void)loadDataWithCompleted:(void (^)())completedBlock {
    NSDictionary *cookie = @{CookieVaule : [UserDefaultsTool stringForKey:XHToken]};
    NSDictionary *param = @{};
    __weak typeof(self) weakSelf = self;
    [HTTPSTool POSTRequestWithPath:@"" cookie:cookie params:param success:^(NSDictionary * _Nonnull JSON) {
        weakSelf.array = [Settlement instanceWithDictionary:JSON];
        completedBlock();
    }];
}

- (NSInteger)numberOfRowsInSection {
    return self.array.count + 1;
}

- (Settlement *)modelInIndexPath:(NSIndexPath *)indexPath {
    if (!self.array) {
        Settlement *settlement = [[Settlement alloc] init];
        settlement.name = @"张**";
        settlement.medicalCard = @"A1254893";
        settlement.orderNumber = @"154896321863";
        settlement.timer = @"2016-09-05";
        settlement.dep = @"骨科";
        settlement.job = @"主任医师";
        settlement.doc = @"陈医生";
        settlement.money = @"8888";
        return settlement;
    }
    return self.array[indexPath.row];
}
@end
